package com.tools.web.interceptor.auth;

import com.tools.common.object.Note;
import com.tools.common.thread.Timeunit;
import org.slf4j.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * AuthToken 的续期工具接口实例
 * */
@Note("AuthToken 的续期工具接口实例")
public interface AuthTokenExtender {

    @Note("判断是否开启了续期功能")
    boolean isEnable();

    @Note("复制一个相同的对象出来")
    AuthTokenExtender copy();

    @Note("AuthToken 续期，并返回续期结果，若为 false 则不允许续期了，必须过期")
    boolean extend(HttpServletRequest request, HttpServletResponse response,
                   AuthenticationManager authenticationManager, Logger logger,
                   String encryptedAccessToken, AuthToken accessToken,
                   Timeunit timeunitUsedBySubclass) throws Exception;

    long getExtendTimeMill();

    long getMaxAllowExtendTimeMill();

    int getMaxAllowExtendCount();
}
